{% extends "layout.html" %}
{% block content %}
    <!--js填充处-->
    <div id="context">

        <!-- Main jumbotron for a primary marketing message or call to action -->
        <div class="jumbotron">
            <div class="container">

                <h4 class="display-4">欢迎访问<br>SUIBE DID Data Manager！</h4>

                <p><a href="" class="btn btn-primary btn-large">查看 Github 源码……</a></p>
            </div>
        </div><!-- /.jumbotron -->

        <div class="container">
            <div class="row">
                <div class="col-lg-8">
                    <a class="no_type_a" target="_blank" ><h3><i class="fa fa-angellist"></i>生成DID</h3></a>
                    <br>
                    <p>
                        <label class="control-label">选择你要生成的DID类型：</label>
                        <br>
                    <div class="selectContainer">
                        <div class="input-group">
                            <span class="input-group-addon"><i class="glyphicon glyphicon-list"></i></span>
                            <select  v-model="key_type" v-on:change="change_key_type(key_type)"  name="select-key-type" class="form-control selectpicker" >
                                {% for item in key_type %}
                                    <option value={{item}}>{{item}}</option>
                                {% endfor %}
                                <option>WeID</option>
                                <option>MicrosoftDID</option>
                                <option>uPort</option>
                            </select>
                        </div>
                    </div>
                    <br>
                    <a class="btn btn-outline-secondary" v-on:click="get_addr()">Generate!</a>
                    </p>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text" id="basic-addon1">DID</span>
                        </div>
                        <input v-model="DID" type="text" class="form-control" placeholder="DID"  aria-describedby="basic-addon1">
                    </div>
                    <div class="input-group mb-3">
                        <div class="input-group-prepend">
                            <span class="input-group-text" id="basic-addon1">PrivKey</span>
                        </div>
                        <input v-model="PrivKey" type="text" class="form-control" placeholder="PrivKey"  aria-describedby="basic-addon1">
                    </div>


                </div>
            </div><!-- /.row -->

            <br>

            <div class = "row">
                <div class="col-lg-8">
                    <a class="no_type_a"><h3><i class="fa fa-flask"></i> DID识别</h3></a>

                    <div class="form-group">
                        <br>
                        <a class="btn btn-outline-secondary" v-on:click="DistinDID()">识别</a>
                        </p>
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text" id="basic-addon1">DID：</span>
                            </div>
                            <input  v-model="vdid" type="text" class="form-control"   aria-describedby="basic-addon1" placeholder="请输入您要识别的DID">
                        </div>

                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text" id="basic-addon1">识别结果：</span>
                            </div>
                            <input v-model="result" type="text" class="form-control"   aria-describedby="basic-addon1">
                        </div>

                    </div>
                </div>
            </div><!-- /.row -->

            <br>




        </div>

        <script>


            function F_Open_dialog()
            {
                document.getElementById("btn_file").click();
            }

            function btn_clear() {
                localStorage.clear();
                location.reload();
            }

            var context=new Vue({
                el: "#context",
                data:
                    {
                        DID: "",
                        key_type:"WeID",
                        result:"",
                        PrivKey:"",
                        vdid:""

                    },
                methods:
                    {

                        DistinDID:function (){
                            console.log(this.vdid)
                            if(this.vdid.search("weid")&&this.vdid!=""){
                                this.result="WeId"
                            }else{
                                this.result="不在识别库"
                            }


                        },
                        get_addr:function() {

                            axios(
                                {
                                    method: 'get',
                                    url: '/did_engine/create_weid_local_func',
                                    headers: {
                                        'Content-Type': 'application/x-www-form-urlencoded',
                                    }
                                })
                                .then(function (response) {
                                    context.DID=response.data.data.weId
                                    context.PrivKey=response.data.data.privateKeyHex
                                    console.log(response.data.data.weId)
                                })
                                .catch(function (error) {
                                })


                        },

                    }

            })
        </script>
{% endblock %}